package com.jzj.Dao.impl;

import com.jzj.Dao.Basedao;
import com.jzj.entity.Movie;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;


public class All extends Basedao {
    Connection connection;
    PreparedStatement preparedStatement=null;
    ResultSet resultSet=null;


    public ArrayList<Movie> xianshi(){
        String sql="select movie_id,movie_name,actor,dirctor,movie_time,type_name from movie_info mi inner join type_info ti where mi.type_id=ti.type_id";
        getConnect();
        ArrayList<Movie> arr=new ArrayList();
        try {
            String sele_name="";
            ResultSet a=selectSQL(sql,sele_name);
            while (a.next()){
                String id=a.getString("movie_id");
                String name=a.getString("movie_name");
                String actor=a.getString("actor");
                String dirctor=a.getString("dirctor");
                String movie_time=a.getString("movie_time");
                String type_name=a.getString("type_name");
                arr.add(new Movie(id,name,actor,dirctor,Integer.valueOf(movie_time),type_name));
            }
        }catch (Exception e){
            throw new RuntimeException(e);
        }finally {
            return arr;
        }

    }
    public Boolean Selectname(String name){
        String sql="select * from movie_info where movie_name='"+name+"'";
        ResultSet resultSet=selectSQL(sql,name);
        try {
            while (resultSet.next()){
                return true;
            }
            return false;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            closeConnect();

        }

    }



}
